if (!run) return; /*We have received signal to close*/
rp = info->fe_ring.sring->req_prod;
- rmb();
+ xen_rmb();
for (j = info->fe_ring.req_cons; j != rp; j++)
{
int done = 0, start_seg = 0;
cons = intf->out_cons;
prod = intf->out_prod;
- mb();
+ xen_mb();
size = prod - cons;
if ((size == 0) || (size > sizeof(intf->out)))
buffer->data[buffer->size++] = intf->out[
MASK_XENCONS_IDX(cons++, intf->out)];
- mb();
+ xen_mb();
intf->out_cons = cons;
xc_evtchn_notify(dom->xce_handle, dom->local_port);
cons = intf->in_cons;
prod = intf->in_prod;
- mb();
+ xen_mb();
space = prod - cons;
if (space > sizeof(intf->in))
intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
msg[i];
}
- wmb();
+ xen_wmb();
intf->in_prod = prod;
xc_evtchn_notify(dom->xce_handle, dom->local_port);
} else {
handle_aio_events(mount);
moretodo:
rp = mount->ring.sring->req_prod;
- rmb(); /* Ensure we see queued requests up to 'rp'. */
-
+ xen_rmb(); /* Ensure we see queued requests up to 'rp'. */
+
while ((cons = mount->ring.req_cons) != rp)
{
int i;
cons = intf->out_cons;
prod = intf->out_prod;
- mb();
+ xen_mb();
size = prod - cons;
if ((size == 0) || (size > sizeof(intf->out)))
buffer->data[buffer->size++] = intf->out[
MASK_XENCONS_IDX(cons++, intf->out)];
- mb();
+ xen_mb();
intf->out_cons = cons;
xc_evtchn_notify(dom->xce_handle, dom->local_port);
cons = intf->in_cons;
prod = intf->in_prod;
- mb();
+ xen_mb();
space = prod - cons;
if (space > sizeof(intf->in))
intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
buf[i];
}
- wmb();
+ xen_wmb();
intf->in_prod = prod;
xc_evtchn_notify(dom->xce_handle, dom->local_port);
}
prod = page->out_prod;
if (prod == page->out_cons)
return;
- rmb(); /* ensure we see ring contents up to prod */
+ xen_rmb(); /* ensure we see ring contents up to prod */
for (cons = page->out_cons; cons != prod; cons++) {
union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
int x, y, w, h;
break;
}
}
- mb(); /* ensure we're done with ring contents */
+ xen_mb(); /* ensure we're done with ring contents */
page->out_cons = cons;
xc_evtchn_notify(xenfb->evt_xch, xenfb->fb.port);
}
return -1;
}
- mb(); /* ensure ring space available */
+ xen_mb(); /* ensure ring space available */
XENKBD_IN_RING_REF(page, prod) = *event;
- wmb(); /* ensure ring contents visible */
+ xen_wmb(); /* ensure ring contents visible */
page->in_prod = prod + 1;
return xc_evtchn_notify(xenfb->evt_xch, xenfb->kbd.port);
}
return NULL;
}
- rmb(); /* see IOREQ_READY /then/ read contents of ioreq */
+ xen_rmb(); /* see IOREQ_READY /then/ read contents of ioreq */
req->state = STATE_IOREQ_INPROCESS;
return req;
__handle_ioreq(env, &req);
- mb();
+ xen_mb();
buffered_io_page->read_pointer += qw ? 2 : 1;
}
}
return;
}
- wmb(); /* Update ioreq contents /then/ update state. */
+ xen_wmb(); /* Update ioreq contents /then/ update state. */
/*
* We do this before we send the response so that the tools
*/
#if defined(__i386__)
-#define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define wmb() __asm__ __volatile__ ( "" : : : "memory")
+#define xen_mb() asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" )
+#define xen_rmb() asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" )
+#define xen_wmb() asm volatile ( "" : : : "memory")
#elif defined(__x86_64__)
-#define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
-#define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
-#define wmb() __asm__ __volatile__ ( "" : : : "memory")
+#define xen_mb() asm volatile ( "mfence" : : : "memory")
+#define xen_rmb() asm volatile ( "lfence" : : : "memory")
+#define xen_wmb() asm volatile ( "" : : : "memory")
#elif defined(__ia64__)
-#define mb() __asm__ __volatile__ ("mf" ::: "memory")
-#define rmb() __asm__ __volatile__ ("mf" ::: "memory")
-#define wmb() __asm__ __volatile__ ("mf" ::: "memory")
+#define xen_mb() asm volatile ("mf" ::: "memory")
+#define xen_rmb() asm volatile ("mf" ::: "memory")
+#define xen_wmb() asm volatile ("mf" ::: "memory")
#elif defined(__powerpc__)
-/* XXX loosen these up later */
-#define mb() __asm__ __volatile__ ("sync" : : : "memory")
-#define rmb() __asm__ __volatile__ ("sync" : : : "memory") /* lwsync? */
-#define wmb() __asm__ __volatile__ ("sync" : : : "memory") /* eieio? */
+#define xen_mb() asm volatile ("sync" : : : "memory")
+#define xen_rmb() asm volatile ("sync" : : : "memory") /* lwsync? */
+#define xen_wmb() asm volatile ("sync" : : : "memory") /* eieio? */
#else
#error "Define barriers"
#endif
{
while ( meta[i]->cons != meta[i]->prod )
{
- rmb(); /* read prod, then read item. */
+ xen_rmb(); /* read prod, then read item. */
rec_size = process_record(
i, (struct t_rec *)(data[i] + meta[i]->cons % data_size));
- mb(); /* read item, then update cons. */
+ xen_mb(); /* read item, then update cons. */
meta[i]->cons += rec_size;
}
}
/* Must read indexes once, and before anything else, and verified. */
cons = intf->rsp_cons;
prod = intf->rsp_prod;
- mb();
+ xen_mb();
if (!check_indexes(cons, prod)) {
errno = EIO;
len = avail;
memcpy(dest, data, len);
- mb();
+ xen_mb();
intf->rsp_prod += len;
xc_evtchn_notify(xce_handle, conn->domain->port);
/* Must read indexes once, and before anything else, and verified. */
cons = intf->req_cons;
prod = intf->req_prod;
- mb();
+ xen_mb();
if (!check_indexes(cons, prod)) {
errno = EIO;
len = avail;
memcpy(data, src, len);
- mb();
+ xen_mb();
intf->req_cons += len;
xc_evtchn_notify(xce_handle, conn->domain->port);
/* Read window information only once. */
cons = meta[i]->cons;
prod = meta[i]->prod;
- rmb(); /* read prod, then read item. */
-
+ xen_rmb(); /* read prod, then read item. */
+
if ( cons == prod )
continue;
outfd);
}
- mb(); /* read buffer, then update cons. */
+ xen_mb(); /* read buffer, then update cons. */
meta[i]->cons = prod;
}
#ifndef __XEN_PUBLIC_IO_RING_H__
#define __XEN_PUBLIC_IO_RING_H__
+#include "../xen-compat.h"
+
+#if __XEN_INTERFACE_VERSION__ < 0x00030208
+#define xen_mb() mb()
+#define xen_rmb() rmb()
+#define xen_wmb() wmb()
+#endif
+
typedef unsigned int RING_IDX;
/* Round a 32-bit unsigned constant down to the nearest power of two. */
(((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
#define RING_PUSH_REQUESTS(_r) do { \
- wmb(); /* back sees requests /before/ updated producer index */ \
+ xen_wmb(); /* back sees requests /before/ updated producer index */ \
(_r)->sring->req_prod = (_r)->req_prod_pvt; \
} while (0)
#define RING_PUSH_RESPONSES(_r) do { \
- wmb(); /* front sees responses /before/ updated producer index */ \
+ xen_wmb(); /* front sees resps /before/ updated producer index */ \
(_r)->sring->rsp_prod = (_r)->rsp_prod_pvt; \
} while (0)
#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do { \
RING_IDX __old = (_r)->sring->req_prod; \
RING_IDX __new = (_r)->req_prod_pvt; \
- wmb(); /* back sees requests /before/ updated producer index */ \
+ xen_wmb(); /* back sees requests /before/ updated producer index */ \
(_r)->sring->req_prod = __new; \
- mb(); /* back sees new requests /before/ we check req_event */ \
+ xen_mb(); /* back sees new requests /before/ we check req_event */ \
(_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) < \
(RING_IDX)(__new - __old)); \
} while (0)
#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do { \
RING_IDX __old = (_r)->sring->rsp_prod; \
RING_IDX __new = (_r)->rsp_prod_pvt; \
- wmb(); /* front sees responses /before/ updated producer index */ \
+ xen_wmb(); /* front sees resps /before/ updated producer index */ \
(_r)->sring->rsp_prod = __new; \
- mb(); /* front sees new responses /before/ we check rsp_event */ \
+ xen_mb(); /* front sees new resps /before/ we check rsp_event */ \
(_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) < \
(RING_IDX)(__new - __old)); \
} while (0)
(_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \
if (_work_to_do) break; \
(_r)->sring->req_event = (_r)->req_cons + 1; \
- mb(); \
+ xen_mb(); \
(_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \
} while (0)
(_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \
if (_work_to_do) break; \
(_r)->sring->rsp_event = (_r)->rsp_cons + 1; \
- mb(); \
+ xen_mb(); \
(_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \
} while (0)
#ifndef __XEN_PUBLIC_XEN_COMPAT_H__
#define __XEN_PUBLIC_XEN_COMPAT_H__
-#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030207
+#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030208
#if defined(__XEN__) || defined(__XEN_TOOLS__)
/* Xen is built with matching headers and implements the latest interface. */